package ie.deloitte.cvapp.createcv;

import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.exceptions.InvalidFormatException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;

import ie.deloitte.cvapp.domain.Employee;


public class CreateCV {

	public void create(java.io.File file, Employee e) throws InvalidFormatException,
			Docx4JException {
		
		
		WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
				.load(new java.io.File("C:/Java/template2.docx"));
		
//		String inputfilepath="C:\\JavaBootcamp\template.docx";
//		wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));

		MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
		//LoadFromZipNG loader = new LoadFromZipNG();
		//WordprocessingMLPackage pkg = (WordprocessingMLPackage)loader.get(Stream);
		
		
		mdp.addStyledParagraphOfText("Heading", e.getName() + " " + e.getSurname() + " CV ");
		mdp.addParagraphOfText("Title:    "  );
//		mdp.addParagraphOfText("Name: " + e.getSurname() + ", " + e.getName());
		mdp.addParagraphOfText("Proposed Role: (bold)" + e.getRoleproposed());
		mdp.addParagraphOfText("Tel:    +353 (1) 417 " + e.getSecondarytelepohne());
		mdp.addParagraphOfText("Proposed Role: " + e.getRoleproposed());
		mdp.addParagraphOfText("Email:    " + e.getEmail());
		mdp.addParagraphOfText("Office:    " );

		mdp.addParagraphOfText(" ");
		mdp.addParagraphOfText("Bio: " + e.getProfile());
		
		
		wordMLPackage.save(file);
	}

}
